package com.xqboss.web.core.config;

import cn.hutool.core.date.LocalDateTimeUtil;
import com.xqboss.common.utils.StringUtils;
import org.springframework.core.convert.converter.Converter;

import java.time.LocalDateTime;

/**
 * <p>
 * 编码 -> 枚举 转化器工厂类
 * </p>
 * @author Trent
 * @date 2023/8/19
 */

public class StringToLocalDateTimeConverter implements Converter<String, LocalDateTime> {

    @Override
    public LocalDateTime convert(String source) {
        if(StringUtils.isEmpty(source)){
            return null;
        }
        long time = Long.parseLong(source);
        return LocalDateTimeUtil.of(time);
    }
}